package org.qy137.controller;

import com.qy137.vo.CourseVo;
import io.swagger.annotations.ApiOperation;
import org.qy137.service.ZoneCourseService;
import org.qy137.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"zoneCourse"})
public class ZoneCourseController {
    @Autowired
    private ZoneCourseService zoneCourseService;

    public ZoneCourseController() {
    }

    @ApiOperation("查询专区下的课程")
    @GetMapping({"getAllDetail/{page}/{limit}"})
    public CommonResult getAllDetail(@PathVariable Integer page, @PathVariable Integer limit, @RequestBody CourseVo courseVo) {
        System.out.println(courseVo.getCourseTitle() + "-------------------------");
        return this.zoneCourseService.getAllDetail(page, limit, courseVo);
    }

    @ApiOperation("删除专区课程")
    @DeleteMapping({"deleteZoneCourse/{id}"})
    public CommonResult deleteZoneCourse(@PathVariable String id) {
        return this.zoneCourseService.deleteZoneCourse(id);
    }

    @ApiOperation("查询所有课程")
    @GetMapping({"getAllCourse/{page}/{limit}"})
    public CommonResult getAllCourse(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, @RequestBody CourseVo courseVoz) {
        return this.zoneCourseService.getAllCourse(page, limit, courseVoz);
    }

    @ApiOperation("添加课程专区的课程")
    @PostMapping({"addZoneCourse/{zoneId}/{courseId}"})
    public CommonResult addZoneCourse(@PathVariable String zoneId, @PathVariable String courseId) {
        return this.zoneCourseService.addZoneCourse(zoneId, courseId);
    }
}
